﻿using System;
using System.Web.UI.Design;
using System.IO;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Library.WebControls.SimpleDateEdit {
	public class SpDateEditDesign : ControlDesigner {
		public override string GetDesignTimeHtml() {

			return GetDesignTimeHtml((SpDateEdit)Component);
		}

		internal static string GetDesignTimeHtml(SpDateEdit de) {

			var txt = new TextBox();
			var deTextBox = ((TextBox)de.TextEdit);
			txt.Width = deTextBox.Width;
			txt.Text = deTextBox.Text;
			txt.MergeStyle(deTextBox.ControlStyle);
			var sw = new StringWriter();
			var tw = new HtmlTextWriter(sw);
			if (!String.IsNullOrEmpty(de.CssFileName)) {
				var link = (de.CreateCssLink(de.ResolveClientUrl(de.CssFileName)));
				if (link != null) {
					link.RenderControl(tw);
				}
			}
			txt.RenderControl(tw);
			return sw.ToString();
		}
	}
}
